﻿<Window x:Class="Adan.Client.Dialogs.ProfilesEditDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Utils="clr-namespace:Adan.Client.Common.Utils;assembly=Adan.Client.Common"
        Title="Choose profile" 
        ResizeMode="NoResize" 
        ShowInTaskbar="False" 
        WindowStartupLocation="CenterOwner" 
        WindowStyle="ToolWindow" 
        mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        Width="300"
        Height="300"
        Name="ProfilesEditorWindow"
        Style="{StaticResource DefaultWindowStyle}">
    <Window.Resources>
        <Utils:InverseBooleanConverter x:Key="InverseBooleanConverter" />
    </Window.Resources>
    <Grid Margin="3">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <ListBox Grid.Row="0" Margin="0,0,0,5" ItemsSource="{Binding Path=Profiles}" SelectedValue="{Binding Path=SelectedProfile}" Name="lstProfiles">
            <ListBox.Resources>
                <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
                    <EventSetter Event="MouseDoubleClick" Handler="HandleItemDoubleClick"/>
                </Style>
            </ListBox.Resources>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch" Background="Transparent">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding Path=NameProfile}" IsEnabled="{Binding Path=IsDefault, Converter={StaticResource InverseBooleanConverter}}" Margin="10,0,0,3" VerticalAlignment="Center" Grid.Column="0"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <StackPanel Grid.Row="1" Margin="0,0,0,5">
            <Label>New profile name:</Label>
            <TextBox Text="{Binding Path=NewProfileName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Name="txtNewProfileName" AcceptsReturn="False"/>
        </StackPanel>
        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,5">
            <Button HorizontalAlignment="Left" Command="{Binding Path=EditProfileCommand}" CommandParameter="{Binding ElementName=ProfilesEditorWindow, Path=.}"  MinWidth="50">Edit</Button>
        </StackPanel>
        <Grid Grid.Row="3">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0"  HorizontalAlignment="Left" Command="{Binding Path=AddProfileCommand}" CommandParameter="{Binding ElementName=txtNewProfileName, Path=Text}" MinWidth="50">Add</Button>
            <Button Grid.Column="1" HorizontalAlignment="Left" Margin="5,0,0,0" Command="{Binding Path=DeleteProfileCommand}" CommandParameter="{Binding ElementName=lstProfiles, Path=SelectedItem}" MinWidth="50">Delete</Button>
            <Button Grid.Column="2"  Click="HandleCloseClick" HorizontalAlignment="Right" IsDefault="True" IsCancel="True" MinWidth="50">Close</Button>
        </Grid>
    </Grid>
</Window>
